<?php
/*!
 * Theme Name:One Nav
 * Theme URI:https://www.iotheme.cn/
 * Author:iowen
 * Author URI:https://www.iowen.cn/
 */
if ( ! defined( 'ABSPATH' ) ) { exit; }  ?>
    <div class="hot-card-body">
        <div class="card hot-card mb-2">
            <div class="card-header widget-header d-flex" style="background-color:transparent;border-bottom:0">
                <span><i class="mr-2 iconfont <?php echo $ico ?>" style="color:<?php echo $color ?>"></i><?php echo $title ?></span>
                <span class="ml-auto d-none d-md-block text-xs"><?php echo $slug ?></span>
            </div>
            <div class="card-body pb-3 pt-0">
                <div class="overflow-auto hot-body">
                    <div id="hot_news-<?php echo $t ?>">
                    </div>
                </div>
                <div class="d-flex text-xs text-muted pt-2 mb-n2">
                    <a href= "<?php echo home_url('/hotnews/') ?>" title='<?php _e('更多','i_theme') ?>' style="color:#6c757d; <?php echo ((is_home() || is_front_page())?'':'display:none') ?>" ><?php _e('更多','i_theme') ?></a>
                    <div class="flex-fill"></div>
                    <span><a href= "javascript:" id="hot-lod-<?php echo $t ?>" title='刷新' style="color:#6c757d" ><i class="iconfont icon-refresh icon-lg"></i></a></span>
                </div>
            </div>
        </div>
        <div id="hot-loading-<?php echo $t ?>" class="ajax-loading text-center rounded" style="position:absolute;display:flex;width:100%;left:0;top:0;bottom:.5rem;background:rgba(125,125,125,.5)"><div id="hot-success-<?php echo $t ?>" class="col align-self-center"><i class="iconfont icon-loading icon-spin icon-2x"></i></div></div>
    </div>
<script>
(function($){ 
    var apiurl =  "<?php echo $type ?>" ;
    getList(apiurl);
    
    $('#hot-lod-<?php echo $t ?>').on('click', function() {
        $(this).children('i').addClass('icon-spin');
        $("#hot-success-<?php echo $t ?>").html('<i class="iconfont icon-loading icon-spin icon-2x"></i>');
        $("#hot-loading-<?php echo $t ?>").fadeIn(200); 
        getList(apiurl);
    });
    function getList(_type){
        $.post("<?php echo $api ?>", { type: _type ,key:"<?php echo iowenKey() ?>" },function(data,status){ 
            var html = '';
            for(var i=0;i<data.length;i++) {
                html += '<div class="text-sm mb-3">'+
                '<div class="mb-1"><span class="hot-rank hot-rank-'+ (i+1) +' text-xs text-center">'+ (i+1) +'</span><a class="ml-2" data-fancybox data-type="iframe" data-src="'+data[i]['link'].replace(/^https?:/,"")+'" href="javascript:;">'+data[i]['title']+'</a></div>'+
                '<div class="d-flex">'+
                '<span class="hot-platform text-xs text-center"><span>'+ (data[i]['platform'])+'</span></span><div class="ml-auto d-none d-md-block">'+data[i]['price']+'</div>'+
                '</div></div>';
            } 
            $("#hot-loading-<?php echo $t ?>").fadeOut(200); 
            $('#hot-lod-<?php echo $t ?>').children('i').removeClass('icon-spin');
            $("#hot_news-<?php echo $t ?>").html(html);
        }).fail(function () {
            $('#hot-lod-<?php echo $t ?>').children('i').removeClass('icon-spin');
            $("#hot-success-<?php echo $t ?>").show(200).html('获取失败，请再试一次！').parent().delay(3500).fadeOut(200); 
        });
    }
})(jQuery)
</script> 